<template>
	<view class="journey-container">
		<view class="content">
			<view class="title">
				我报名的活动
			</view>
			<view class="list">
				<view class="list-scroll-container">
					<!-- scrolltolower事件可以监听加载到底部 -->
					<scroll-view scroll-y="true" class="list-scroll" @scrolltolower="loadMore">
						<view v-for="(item,index) in list" :key="index">
							<view class="list-card">
								<view @click="goDetail(item)">
									<view class="list-card-top">
										<view>{{item.recruitInfo.title}}</view>
										<view class="status">{{item.status}}</view>
									</view>
									<view class="list-card-middle">
										<swiper :indicator-dots="true" :autoplay="true" :interval="3000"
											:duration="1000">
											<swiper-item v-for="(demo,id) in item.recruitInfo.imgArr" :key="id">
												<image :src="demo" mode=""></image>
											</swiper-item>
										</swiper>
									</view>
									<view class="list-card-bottom">
										<view class="article-type">
											{{item.recruitInfo.province}}
										</view>
										<view class="browser-number">
											{{item.recruitInfo.scan}} 浏览
										</view>
									</view>
								</view>
							</view>
						</view>
						<uni-load-more v-if="list.length > 5 && isShowLoadMore" :status="loadData || 'loading'">
						</uni-load-more>
					</scroll-view>
				</view>
			</view>
		</view>
		<view class="no-data" v-if="list.length===0">
			暂无报名的活动
		</view>

	</view>
</template>
<script>
	import {
		getEnrollInfo
	} from "../../ajax/api/qiye.js";
	import {
		mapState
	} from "vuex";
	export default {
		data() {
			return {
				current: 1,
				pageSize: 5,
				list: [],
			}
		},
		computed: {
			...mapState(["userInfo"])
		},
		async onShow() {
			const res = await getEnrollInfo({
				current: this.current,
				pageSize: this.pageSize,
				user: this.userInfo._id
			})
			this.list = res.rows;
			this.list.forEach((item) => {
				if (item.status === 0) {
					item.status = "待审核"
				} else if (item.status === 1) {
					item.status = "审核不通过"
				} else {
					item.status = "审核通过"
				}
			})
		},
		methods: {
			// 进入详情页
			goDetail(item) {
				this.$Router.push({
					path: "/pages/journey/journeyDetail/journeyDetail",
					query: {
						item: JSON.stringify(item.recruitInfo)
					}
				})
			}
		}
	}
</script>
<style lang="scss" scoped>
	@import "./css/journey.scss";
</style>
